﻿using DreamCMS.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DreamCMS.BLL.Factory.Interface;
using DreamCMS.BLL.Factory;

namespace DreamCMS.BLL
{
    public class SiteSettingManager
    {
        private static ISiteSettingDAO dao = DataAccessFactory.CreateSiteSettingDAO();

        private static SiteSettingInfo setting;

        static object lockHelper = new object();
        static SiteSettingManager()
        {
            if(setting==null)
            {
                lock(lockHelper)
                {
                    if(setting==null)
                    {
                        setting = dao.GetSiteSetting();
                    }
                }
            }
        }
        /// <summary>
        /// 获取站点设置
        /// </summary>
        /// <returns></returns>
        public static SiteSettingInfo GetSiteSettingInfo()
        {
            return SiteSettingManager.setting;
        }
        /// <summary>
        /// 更新站点设置
        /// </summary>
        /// <returns></returns>
        public static bool UpdateSettingInfo()
        {
            return dao.UpdateSetting(setting);
        }
    }
}
